package com.lms.busi.common.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lms.busi.common.mapper.TLmsStaffWorkMapper;
import com.lms.busi.common.service.ITLmsStaffWorkService;
import com.lms.common.entity.TLmsStaffWork;
import com.lms.common.web.service.impl.WrapperServiceImpl;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.Map;

@Service
public class TLmsStaffWorkServiceImpl extends WrapperServiceImpl<TLmsStaffWorkMapper, TLmsStaffWork> implements ITLmsStaffWorkService {
    @Override
    public IPage<?> queryMapper(Page<TLmsStaffWork> page, Map<String, Object> p) {
        QueryWrapper<TLmsStaffWork> params = new QueryWrapper<>();
        // 关联员工id
        if (p.get("staffId") != null) {
            params.eq("staff_id", p.get("staffId"));
        }
        return this.baseMapper.selectPage(page, params);
    }

    @Override
    public void deleteByStaffId(Serializable staffId) {
        QueryWrapper<TLmsStaffWork> params = new QueryWrapper<>();
        // 关联员工id
        params.eq("staff_id", staffId);
        this.remove(params);
    }
}
